package demo4;
//类可以实现一个普通类
//类还可以实现一个抽象类
//类可以实现一个普通类/抽象类的同时，实现多个接口

//接口可以通过extends拓展多个接口的功能


abstract class Animal {
    public String name;

    public Animal(String name) {
        this.name= name;
    }
}

interface IRunning {
    void run();
}
interface  ISwimming {
    void swim();
}
interface  IFly {
    void fly();
}
class Dog extends Animal implements IRunning{

    public Dog(String name) {
        super(name);
    }


    @Override
    public void run() {

        System.out.println(name + "跑");
    }
}
class Fish extends Animal implements ISwimming {

    public Fish(String name) {
        super(name);
    }

    @Override
    public void swim() {
        System.out.println( name + "游泳");
    }
}
class Bird extends Animal implements IFly {

    public Bird(String name) {
        super(name);
    }

    @Override
    public void fly() {
        System.out.println(name + "飞");
    }
}
class Duck extends Animal implements IRunning,IFly,ISwimming {

    public Duck(String name) {
        super(name);
    }

    @Override
    public void run() {
        System.out.println(name + "跑");
    }

    @Override
    public void swim() {
        System.out.println(name + "游泳");
    }

    @Override
    public void fly() {
        System.out.println(name + "飞");
    }
}
class Robot implements IRunning {

    @Override
    public void run() {
        System.out.println("机器人会跑");
    }
}

public class Test {

    public static void walk(IRunning iRunning) {
        iRunning.run();
    }
    public static void swim(ISwimming iSwimming) {
        iSwimming.swim();
    }
    public static void fly(IFly iFly) {
        iFly.fly();
    }

    public static void main(String[] args) {
        walk(new Dog("阿I"));
        walk(new Duck("阿e"));
        walk(new Robot());

        swim(new Fish("阿p"));
        swim(new Duck("阿e"));

        fly(new Bird("阿J"));
        fly(new Duck("阿e"));
    }
}
